<template>
  <el-card>
    <!-- 柱状图 -->
    <div ref="main" class="main1" />
  </el-card>
</template>

<script>
const echarts = require('echarts/lib/echarts')
require('echarts/lib/component/toolbox')
require('echarts/lib/component/tooltip')
require('echarts/lib/component/grid')
require('echarts/lib/component/legend')
require('echarts/lib/chart/bar')
require('echarts/lib/component/title')
export default {
  mounted() {
    // 实例化图标
    const myChart = echarts.init(this.$refs.main)
    var option
    // 实际绘图配置
    const labelOption = {}
    option = {
      title: {
        text: '公寓免费入住',
        subtext: '还配送女生'
      },
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'shadow'
        }
      },
      legend: {
        data: ['公寓1', '公寓2', '公寓3']
      },

      xAxis: [
        {
          type: 'category',
          axisTick: { show: false },
          data: ['2012', '2013', '2014', '2015', '2016']
        }
      ],
      yAxis: [
        {
          type: 'value'
        }
      ],
      grid: {
        show: true,
        right: 280,
        left: 30,
        bottom: 20
      },
      series: [
        {
          name: '公寓1',
          type: 'bar',
          label: labelOption,
          emphasis: {
            focus: 'series'
          },
          data: [320, 332, 301, 334, 390]
        },
        {
          name: '公寓2',
          type: 'bar',
          label: labelOption,
          emphasis: {
            focus: 'series'
          },
          data: [220, 182, 191, 234, 290]
        },
        {
          name: '公寓3',
          type: 'bar',
          label: labelOption,
          emphasis: {
            focus: 'series'
          },
          data: [150, 232, 201, 154, 190]
        }
      ]
    }

    option && myChart.setOption(option)
  }
}
</script>

<style lang="scss">
.main1{
    width: 1000px;
    height: 500px;
}
</style>
